package com.isunland.managesystem.ui;

import com.google.gson.Gson;
import com.isunland.managesystem.base.BaseNetworkDialogFragment;
import com.isunland.managesystem.common.ApiConst;
import com.isunland.managesystem.entity.CustomerDialog;
import com.isunland.managesystem.entity.rProductsListMain;
import com.isunland.managesystem.entity.rProductsListMainListOriginal;
import java.util.ArrayList;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2017/3/23 12:37
 */

public class CropInfoDialogFragment extends BaseNetworkDialogFragment {
  @Override public String getUrl() {
    return ApiConst.URL_QUERY_LIST_R_PRODUCTS_LIST_MAIN;
  }

  @Override public ArrayList<CustomerDialog> resolveResponse(String arg0) {
    ArrayList<CustomerDialog> list = new ArrayList<>();
    rProductsListMainListOriginal original =
        new Gson().fromJson(arg0, rProductsListMainListOriginal.class);
    ArrayList<rProductsListMain> rows = original.getRows();
    if (rows == null || rows.size() == 0) {

      return null;
    }
    for (int i = 0; i < rows.size(); i++) {
      list.add(new CustomerDialog(rows.get(i).getProductName(), rows.get(i).getId(),
          rows.get(i).getMtype()));
    }
    return list;
  }
}
